//
//  YSColorViewController.m
//  YSKitDemo
//
//  Created by MOLBASE on 2018/8/9.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "YSColorViewController.h"
#import "UIImage+YSFromColor.h"

@interface YSColorViewController ()

@end

@implementation YSColorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CGFloat w = 100;
    CGFloat h = 60;
    CGFloat x = (self.view.ys_width - 40 - 2*w) / 2;
    CGFloat y = 100;
    CGFloat space = 20;
    
    UIButton *leftbutton = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
    [leftbutton setTitle:@"←←←←B" forState:UIControlStateNormal];
    [leftbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"0000FF"), [UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionLeft] forState:UIControlStateNormal];
    [self.view addSubview:leftbutton];
    
    UIButton *rightbutton = [[UIButton alloc] initWithFrame:CGRectMake(x+w+space, y, w, h)];
    [rightbutton setTitle:@"→→→→B" forState:UIControlStateNormal];
    [rightbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"0000FF"), [UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionRight] forState:UIControlStateNormal];
    [self.view addSubview:rightbutton];
    
    UIButton *topbutton = [[UIButton alloc] initWithFrame:CGRectMake(x, y+h+space, w, h)];
    [topbutton setTitle:@"↑↑↑↑B" forState:UIControlStateNormal];
    [topbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"0000FF"), [UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionTop] forState:UIControlStateNormal];
    [self.view addSubview:topbutton];
    
    UIButton *bottombutton = [[UIButton alloc] initWithFrame:CGRectMake(x+w+space, y+h+space, w, h)];
    [bottombutton setTitle:@"↓↓↓↓B" forState:UIControlStateNormal];
    [bottombutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"0000FF"), [UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionBottom] forState:UIControlStateNormal];
    [self.view addSubview:bottombutton];
    
    UIButton *topleftbutton = [[UIButton alloc] initWithFrame:CGRectMake(x, y+2*(h+space), w, h)];
    [topleftbutton setTitle:@"↖︎↖︎↖︎↖︎B" forState:UIControlStateNormal];
    [topleftbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[[UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionTopLeft] forState:UIControlStateNormal];
    [self.view addSubview:topleftbutton];
    
    UIButton *toprightbutton = [[UIButton alloc] initWithFrame:CGRectMake(x+w+space, y+2*(h+space), w, h)];
    [toprightbutton setTitle:@"↗︎↗︎↗︎↗︎B" forState:UIControlStateNormal];
    [toprightbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[[UIColor ys_colorFromHexString:@"FF00FF"], [UIColor ys_colorFromHexString:@"ffff00"]] direction:YSGradientDirectionTopRight] forState:UIControlStateNormal];
    [self.view addSubview:toprightbutton];
    
    UIButton *bottomleftbutton = [[UIButton alloc] initWithFrame:CGRectMake(x, y+3*(h+space), w, h)];
    [bottomleftbutton setTitle:@"↙︎↙︎↙︎↙︎B" forState:UIControlStateNormal];
    [bottomleftbutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"FF00FF"), YSHexColor(@"ffff00")] direction:YSGradientDirectionBottomLeft] forState:UIControlStateNormal];
    [self.view addSubview:bottomleftbutton];
    
    UIButton *bottomrightutton = [[UIButton alloc] initWithFrame:CGRectMake(x+w+space, y+3*(h+space), w, h)];
    [bottomrightutton setTitle:@"↘︎↘︎↘︎↘︎B" forState:UIControlStateNormal];
    [bottomrightutton setBackgroundImage:[UIImage ys_imageWithGradientColors:@[YSHexColor(@"FF00FF"), YSHexColor(@"ffff00")] direction:YSGradientDirectionBottomRight] forState:UIControlStateNormal];
    [self.view addSubview:bottomrightutton];
    
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y+4*(h+space), w, h)];
//    [label setGradientLayerWithColors:@[YSHexColor(@"0000FF"), YSHexColor(@"FF00FF"), YSHexColor(@"ffff00")] direction:YSGradientDirectionLeft];
//    label.text = @"←←←←L";
//    [self.view addSubview:label];
//
//    UILabel *rlabel = [[UILabel alloc] initWithFrame:CGRectMake(x+w+space, y+4*(h+space), w, h)];
//    [rlabel setGradientLayerWithColors:@[YSHexColor(@"0000FF"), YSHexColor(@"FF00FF"), YSHexColor(@"ffff00")] direction:YSGradientDirectionLeft];
//    rlabel.text = @"→→→→L";
//    [self.view addSubview:rlabel];
    
}

@end
